<template>
  <a-card class="ax_sticky_top">
    <template #title>
        参数配置列表
    </template>
    <template #extra>
      <a-tooltip title="前往帮助中心">
        <a class="system__icon" target="_blank">
          <QuestionCircleTwoTone/>
        </a>
      </a-tooltip>
    </template>
    <div class="mb-12 grid grid-cols-6 gap-4">
              <a-input
                  v-model:value="configTable.query.configName"
                  class="flex-1"
                  placeholder="请输入参数名称"
                  @press-enter="configSearch"
                  allow-clear
              ></a-input>
              <a-input
                  v-model:value="configTable.query.configKey"
                  class="flex-1"
                  placeholder="请输入参数键名"
                  @press-enter="configSearch"
                  allow-clear
              ></a-input>
      <div class="text-right">
        <a-button type="primary" @click="configSearch">搜索</a-button>
      </div>
    </div>
    <a-flex justify="space-between" :align="'center'">
      <a-flex justify="space-between" :align="'center'">
        <a-flex :align="'center'" :gap="4">

          <div v-perm="'system:config:add'">
            <a-tooltip title="新建">
              <a-button type="primary" @click="configCreate">
                <PlusOutlined/>
              </a-button>
            </a-tooltip>
          </div>

          <div v-perm="'system:config:edit'">
            <a-tooltip title="编辑">
              <a-button type="link" @click="configEdit()" :disabled="configTable.keys.length !== 1">
                <EditOutlined/>
              </a-button>
            </a-tooltip>
          </div>
          <div v-perm="'system:config:list'">
            <a-tooltip title="刷新">
              <a-button type="link" @click="configList">
                <SyncOutlined/>
              </a-button>
            </a-tooltip>
          </div>
          <div v-perm="'system:config:remove'">
            <a-popconfirm
                title="确定要删除吗"
                :disabled="configTable.keys.length === 0"
                placement="bottomRight"
                @confirm="configDelete()"
            >
              <a-tooltip title="批量删除">
                <a-button danger type="link" :disabled="configTable.keys.length === 0">
                  <DeleteOutlined/>
                </a-button>
              </a-tooltip>
            </a-popconfirm>
          </div>
        </a-flex>

      </a-flex>
      <a-flex>
        <div v-perm="'system:config:export'">
          <a-tooltip title="下载数据">
            <a-button type="link" @click="configExport">
              <DownloadOutlined/>
            </a-button>
          </a-tooltip>
        </div>
        <div v-perm="'system:config:add'">
          <a-tooltip title="导入数据">
            <a-button type="link" @click="configImport">
              <UploadOutlined/>
            </a-button>
          </a-tooltip>
        </div>

        <FieldVue :raw="configRawColumns" v-model:columns="configColumns"
                  :module-name="configTable.moduleName"/>
        <div>
          <a-tooltip title="卡片模式" @click="configTable.viewMode = 'card'"
                     v-if="configTable.viewMode === 'table'">
            <a-button type="link">
              <OrderedListOutlined/>
            </a-button>
          </a-tooltip>

          <a-tooltip title="表格模式" @click="configTable.viewMode = 'table'" v-else>
            <a-button type="link">
              <AppstoreAddOutlined/>
            </a-button>
          </a-tooltip>
        </div>
      </a-flex>
    </a-flex>
  </a-card>
</template>

<script setup lang="ts">
  import {
  } from '../../data/options';
  import FieldVue from '@/views/components/table/Field.vue';
  import {configColumns, configRawColumns} from '../../data/column';
  import {
          configCreate,
          configDelete,
          configEdit,
          configList,
          configSearch,
          configImport,
          configExport
  } from '../../data/curd';
  import {configTable} from '../../data/table';


</script>

<style lang="scss" scoped></style>


